﻿#!/usr/bin/env python3
from time import localtime,time


def main():
    '''
string format -

replacement_field ::=  "{" [field_name] ["!" conversion] [":" format_spec] "}"

field_name        ::=  arg_name ("." attribute_name | "[" element_index "]")*
arg_name          ::=  [identifier | digit+]
attribute_name    ::=  identifier
element_index     ::=  digit+ | index_string
index_string      ::=  <any source character except "]"> +

conversion        ::=  "r" | "s" | "a"              # r - repr, s - str, a - ascii

format_spec     ::=  [[fill]align][sign][#][0][width][grouping_option][.precision][type]
fill            ::=  <any character>
align           ::=  "<" | ">" | "=" | "^"
sign            ::=  "+" | "-" | " "
width           ::=  digit+
grouping_option ::=  "_" | ","
precision       ::=  digit+
type            ::=  "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
                    # b, binary; c, character; d, decimal; o, octal; x and X, hex; n, number with seperator. 
    '''
    print(main.__doc__)
    print("{0}, {0:b}, {0:o}, {0:x}, {0:n}".format(123456789))
    print("{0}, {0:f}, {0:3f}, {0:3.2f}, {0:06.4}, {0:06.5}".format(1234.5678))
    print("St. {street} , City {city}, ".format(city="Xi'an", street="TaiBai"))
    weekd=("Mon","Tue","Wed","Thi","Fri","Sat","Sun")
    print("{0[2]}".format(weekd))
    
    print("{0.tm_year}".format(localtime(time())))
    print("{:<30}".format("hello"))
    print("{:>30}".format("hello"))
    print("{:^30}".format("hello"))
    





if __name__=='__main__':
    main()


